
var Muse = {
    // 取得列表
    getList: function () {
      let {
        page,
        isFirstLoad,
        loading,
        tagName,
        museLeft,
        museRight,
        windowInfo,
        showFirstLoading
      } = this.data
  
      if (page < 0) {
        // 下拉已到底
        return;
      }
  
      wx.showNavigationBarLoading()
  
      const data = {
        windowWidth: windowInfo.windowWidth,
        page: page
      }

      if (!showFirstLoading) {
        isFirstLoad && wx.showLoading()
      }
  
      isFirstLoad || this.setData({
        loading: true
      })
  
      request({
        url: '/index/Muse/getList.html',
        data
      }).then(res => {
        this.setData({
          isFirstLoad: false
        });
        wx.hideLoading();
        const {
          code,
          data
        } = res.data
        loading = false
        let nomore = false
        if (code == 0) {
          let {
            museLeft,
            museRight,
            nPage
          } = data
          if (nPage < 0) nomore = true
  
          if (page <= 1) {
            // 首页
            this.setData({
              museLeft: museLeft,
              museRight: museRight,
              nomore,
              loading,
              page: nPage
            });
          } else {
            this.setData({
              list: [...list, ...museList],
              nomore,
              loading,
              page: nPage
            })
          }
        }
        this.setData({
          showFirstLoading: false
        })
        wx.stopPullDownRefresh();
        wx.hideNavigationBarLoading();
      }).catch(e => {
        wx.stopPullDownRefresh();
        wx.hideNavigationBarLoading();
        wx.hideLoading();
        this.setData({
          loading: false,
          countError: true,
          showFirstLoading: false
        })
      })
    }
};

module.exports = Muse